<template>
  <el-input
    v-model="value"
    placeholder="Please input"
    class="input-with-select"
    @keydown.enter="handleClick"
  >
    <template #append>
      <el-button type="primary" :icon="Plus" @click="handleClick"></el-button>
    </template>
  </el-input>
</template>
<script>
import { defineComponent, ref } from 'vue'
import { Plus } from '@element-plus/icons-vue'
export default defineComponent({
  name: 'TodoInput',
  emits: ['onChange'],
  setup(props, { emit }) {
    let value = ref('')
    const handleClick = () => {
      if (value.value) {
        emit('onChange', value.value)
        value.value = ''
      }
    }
    return {
      value,
      Plus,
      handleClick,
    }
  },
})
</script>
